{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# [1] SciPy 常量模块 - constants\n",
    "#\n",
    "'''\n",
    "常量模块包含以下几种单位：\n",
    "  公制单位\n",
    "  二进制，以字节为单位\n",
    "  质量单位\n",
    "  角度换算\n",
    "  时间单位\n",
    "  长度单位\n",
    "  压强单位\n",
    "  体积单位\n",
    "  速度单位\n",
    "  温度单位\n",
    "  能量单位\n",
    "  功率单位\n",
    "  力学单位\n",
    "'''\n",
    "from scipy import constants\n",
    "\n",
    "print(constants)\n",
    "# print(dir(constants))       # 使用 dir() 函数来查看 constants 模块包含了哪些常量\n",
    "print(constants.pi)         # 圆周率\n",
    "print(constants.golden)     # 黄金比例\n",
    "print()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# [2] SciPy 常量模块 - 国际单位制词头\n",
    "# 国际单位制词头（英语：SI prefix）表示单位的倍数和分数，目前有 20 个词头，大多数是千的整数次幂。 (centi 返回 0.01)：\n",
    "# \n",
    "from scipy import constants\n",
    "\n",
    "print(constants.yotta)  # 1e+24\n",
    "print(constants.zetta)  # 1e+21\n",
    "print(constants.exa)    # 1e+18\n",
    "print(constants.peta)   # 1e+15\n",
    "print(constants.tera)   # 1e+12\n",
    "print(constants.giga)   # 1e+9\n",
    "print(constants.mega)   # 1e+6\n",
    "print(constants.kilo)   # 1000.0\n",
    "print(constants.hecto)  # 100.0\n",
    "print(constants.deka)   # 10.0\n",
    "print(constants.deci)   # 0.1\n",
    "print(constants.centi)  # 0.01\n",
    "print(constants.milli)  # 0.001\n",
    "print(constants.micro)  # 1e-06\n",
    "print(constants.nano)   # 1e-09\n",
    "print(constants.pico)   # 1e-12\n",
    "print(constants.femto)  # 1e-15\n",
    "print(constants.atto)   # 1e-18\n",
    "print(constants.zepto)  # 1e-21\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# [3] SciPy 常量模块 - 二进制前缀\n",
    "# 返回字节单位 (kibi 返回 1024)。\n",
    "# \n",
    "from scipy import constants\n",
    "\n",
    "print(constants.kibi)    # 2^10 = 1024\n",
    "print(constants.mebi)    # 2^20 = 1048576\n",
    "print(constants.gibi)    # 2^30 = 1073741824\n",
    "print(constants.tebi)    # 2^40 = 1099511627776\n",
    "print(constants.pebi)    # 2^50 = 1125899906842624\n",
    "print(constants.exbi)    # 2^60 = 1152921504606846976\n",
    "print(constants.zebi)    # 2^70 = 1180591620717411303424\n",
    "print(constants.yobi)    # 2^80 = 1208925819614629174706176"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# [4] SciPy 常量模块 - 质量单位\n",
    "# 返回多少千克 kg。(gram 返回 0.001)。\n",
    "#\n",
    "from scipy import constants\n",
    "\n",
    "print(constants.gram)           # 0.001\n",
    "print(constants.metric_ton)     # 1000.0\n",
    "print(constants.grain)          # 6.479891e-05\n",
    "print(constants.lb)             # 0.45359236999999997\n",
    "print(constants.pound)          # 0.45359236999999997\n",
    "print(constants.oz)             # 0.028349523124999998\n",
    "print(constants.ounce)          # 0.028349523124999998\n",
    "print(constants.stone)          # 6.3502931799999995\n",
    "print(constants.long_ton)       # 1016.0469088\n",
    "print(constants.short_ton)      # 907.1847399999999\n",
    "print(constants.troy_ounce)     # 0.031103476799999998\n",
    "print(constants.troy_pound)     # 0.37324172159999996\n",
    "print(constants.carat)          # 0.0002\n",
    "print(constants.atomic_mass)    # 1.66053904e-27\n",
    "print(constants.m_u)            # 1.66053904e-27\n",
    "print(constants.u)              # 1.66053904e-27\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.10.7 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.7"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "60d0b561bcf179bd0cd76361af4313e00281c3c5daca1903769e6cc3dd82b37c"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
